package com.dragon.mmochat.message;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.object.MmochatCommonObject;
import com.dragon.mmochat.model.object.MmochatPackageGrid;
import com.skymobi.buffer.SkymobiBuffer;
import com.skymobi.message.SkymobiProtocolMessage;

public class Mmochat_7_17S extends SkymobiProtocolMessage {
	int dealId;
	MmochatPackageGrid grid;

	public Mmochat_7_17S() {
		setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_7_17);
	}

	@Override
	protected void encodeBody(SkymobiBuffer out) {
		out.putInt(dealId);
		out.putShort((short) grid.getGridIndex());
		out.putShort((short) grid.getGridAttrValue());
		MmochatCommonObject obj = grid.getObject();
		if (obj == null) {
			out.putShort((short) 0);
			out.putShort((short) 0);
			out.putShort((short) 0);
			out.putShort((short) 0);
		} else {
			// attr
			out.putShort((short) obj.getAttrValue());
			// bmpId
			out.putUnsignedShort(obj.getBmpId());
			// info
			out.putPrefixedString(obj.getInfo(), 2);			
			// overlapNum
			out.putShort((short) obj.getOverlapNum());
		}
	}

	public void setGrid(MmochatPackageGrid grid) {
		this.grid = grid;
	}

	public void setDealId(int dealId) {
		this.dealId = dealId;
	}

}
